//
//  DetailModal.m
//  Daybook
//
//  Created by dllo on 16/5/25.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "DetailModal.h"
#import "DetailDayModal.h"

@implementation DetailModal

- (void)setValue:(id)value forKey:(NSString *)key {
    if ([key isEqualToString:@"cell"]) {
        NSArray *tempArr = value;
        NSMutableArray *newArr = [NSMutableArray array];
        for (NSInteger i = 0; i < tempArr.count; i++) {
            NSArray *modalArr = [DetailDayModal baseModalByArr:tempArr[i]];
            [newArr addObject:modalArr];
        }
        self.cellArr = (NSArray *)newArr;
    }else {
        [super setValue:value forKey:key];
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"section"]) {
        NSDictionary *sectionDic = value;
        NSDictionary *moneyDic = [sectionDic valueForKey:@"money"];
        self.sectionInMoney = [moneyDic valueForKey:@"1"];
        self.sectionOutMoney = [moneyDic valueForKey:@"2"];
        self.sectionBalance = [sectionDic valueForKey:@"balance"];
    }else {
        NSLog(@"未找到的key: %@", key);
    }
}

@end
